<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计算窗口垂直滚动条的宽度</title>
    <style>
        .container {
            height: 3500px;
        }
    </style>
</head>
<body>
    <div class="container"></div>
</body>
<script>
    const getScrollbarWidth = () => window.innerWidth - document.documentElement.clientWidth;
    console.log(getScrollbarWidth());
    document.querySelector('.container').innerHTML = getScrollbarWidth();
</script>
</html>